//search on header
$(function() {
    var $header = $('#site-header'),
        $panel = $header.find('.inner');
    // Insert a toggle button
    $header.append('<span class="toggle-button"><a href="/">Search</a></span>');
    // Click the toggle button to slide the panel
    $header.find('.toggle-button a').on("click", function() {
        if ($(this).html() == 'Search') {
            $(this).html('&times;');
        } else {
            $(this).html('Search');
        }
        $panel.slideToggle('slow');
        return false;
    });
});

//tooltip
(function() {

    var a = document.getElementsByTagName('a');
    var t = document.createElement('span');
        t.id = "tt";
        t.style.position = "absolute";
        t.style.zIndex = 999;
        t.style.backgroundColor = "#333";
        t.style.border = "1px solid #fff";
        t.style.font = "bold 11px Tahoma,Arial,Sans-Serif";
        t.style.boxShadow = "0 1px 3px rgba(0,0,0,0.4)";
        t.style.padding = "5px 10px";
        t.style.color = "#999";
        t.style.maxWidth = "170px";
        t.style.wordWrap = "break-word";
        t.style.display = "none";
    document.body.appendChild(t);
    var tooltip = document.getElementById('tt');

    function over(e) {
        tooltip.style.display = "block";
        tooltip.innerHTML = this.title;
        tooltip.style.top = (e.pageY + 25) + 'px';
        tooltip.style.left = e.pageX + 'px';
        this.setAttribute('original', this.title);
        this.title = "";

    }

    function out() {
        tooltip.innerHTML = "";
        tooltip.style.display = "none";
        this.title = this.getAttribute('original');
        this.removeAttribute('original');
    }

    for (var i = 0; i < a.length; i++) {
        if (a[i].title) {
            a[i].onmouseover = over;
            a[i].onmouseout = out;
        }
    }

})();

//block link
function blockLinks(parentID, children) {
    var parent = document.getElementById(parentID),
        content = parent.getElementsByTagName(children);
    for (var i = 0; i < content.length; i++) {
        if (content[i].innerHTML.indexOf('</a>') !== -1) {
            var salinan = content[i].innerHTML;
            content[i].innerHTML = "<div><mark>No live link!!!</mark> Dilarang nyepam di sini!</div><div><textarea>" + salinan + "</textarea></div>";
            content[i].className = "spammer-detected";
        }
    }
}

// Jalankan fungsi!
blockLinks('comment-holder', 'p');

//komen target
var jump = function (e) {
    if (e) {
        var target = jQuery(this).attr(&quot;href&quot;).replace(&#39;/&#39;, &#39;&#39;);
    } else {
        var target = location.hash;
    }
    jQuery(&#39;html,body&#39;).animate({
        scrollTop: (jQuery(target).offset().top) - 100
    }, 500, function () {});
}
jQuery(document).ready(function ($) {
    $(document).on(&#39;click&#39;, &#39;a[href*=#]&#39;, jump);
    if (location.hash) {
        setTimeout(function () {
            $(&#39;html, body&#39;).scrollTop(0).show();
            jump();
        }, 0);
    } else {
        $(&#39;html, body&#39;).show();
    }
});

//emokomen
var emoRange=&quot;#comments p, #threaded-comment-form&quot;,putEmoAbove=&quot;#comment-editor&quot;,emoMessage=&quot;Untuk menyisipkan emoticon setidaknya Anda harus menambahkan satu spasi di awal simbol.&quot;;

//pageloader
$(document.body).append(&#39;&lt;div id=&quot;page-loader&quot;&gt;Loading...&lt;/div&gt;&#39;);$(window).on(&quot;beforeunload&quot;,function(){$(&quot;#page-loader&quot;).fadeIn(1000).delay(6000).fadeOut(1000)});

//scrolltop
$(window).scroll(function() {
    if($(this).scrollTop() &gt; 200) {
        $(&#39;#gotop&#39;).stop().animate({bottom:0,right:0}, 200);
    } else {
        $(&#39;#gotop&#39;).stop().animate({bottom:-30,right:-30}, 200);
    }
});

$(&#39;#gotop&#39;).click(function() {
    $(&#39;html, body&#39;).animate({scrollTop:0}, 1000); 
    return false;
});